package com.choice;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Handler;

public class LauncherUtil {
	private static final int DISPLAY_TIME = 1000;
	private static Handler handler;
	private static Intent intent;
	private static boolean isLayoutDefault = true;
	private static int layoutResource;

	@SuppressLint("NewApi")
	public static final void go(final Activity activity, final Class<?> cls) {

		if (isLayoutDefault == true) {
			activity.setContentView(R.layout.intro_activity);
		}

		else {
			activity.setContentView(layoutResource);
		}

		handler = new Handler();
		handler.postDelayed(new Runnable() {
			
			public void run() {
				intent = new Intent(activity, cls);
				activity.startActivity(intent);
				activity.overridePendingTransition(android.R.anim.fade_in,
						android.R.anim.fade_out);
				activity.finish();
			}
		}, DISPLAY_TIME);
	}

	public static final void go(int _layoutResource, final Activity activity,
			final Class<?> cls) {
		isLayoutDefault = false;
		layoutResource = _layoutResource;
		go(activity, cls);
	}
}